<template>
  <!-- 分类页面组件 -->
  <view class="category_box">
    <navigator class="item_img" v-for="item in category" :key="item.id" 
    :url="`/pages/imgCategory/index?id=${item.id}`">
      <image class="img" :src="item.cover" mode="aspectFill"> </image>
      <view class="text">{{ item.name }}</view>
    </navigator>
  </view>
</template>
<script>
export default {
  mounted() {
    uni.setNavigationBarTitle({
      title: "懂你找图"
    });
    this.getList();
  },
  data() {
    return {
      category: []
    };
  },
  methods: {
    async getList() {
      const res = await this.http({
        url: "http://157.122.54.189:9088/image/v1/vertical/category"
      });
      //console.log(res);
      this.category = res.data.res.category;
    }

    /*  */
  }
};
</script>
<style lang="less" scoped>
.category_box {
  display: flex;
  flex-wrap: wrap;
  .item_img {
    width: 33.3%;

    position: relative;
    border: 5rpx solid #fff;

    .img {
      height: 240rpx;
    }
    .text {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 50rpx;
      padding-left: 15rpx;
      font-size: 40rpx;

      color: #fff;
      background-image: linear-gradient(
        to right top,
        rgba(0, 0, 0, 0.2),
        rgba(0, 0, 0, 0)
      );
      display: flex;
      align-items: center;
    }
  }
}
</style>